#pragma once

#include <iostream>
#include <string>
#include "InetAddr.hpp"

// 封装fd，保证给每一个fd一套缓冲

class TcpServer;

// 基类
class Connection
{
public:
    Connection()
    {
    }
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual void Excepter() = 0;

    void SetEvent(const uint32_t &events)
    {
        _events = events;
    }
    uint32_t GetEvent()
    {
        return _events;
    }
    void SetFd(int sockfd)
    {
        _sockfd = sockfd;
    }
    int GetFd()
    {
        return _sockfd;
    }
    ~Connection()
    {
    }

private:
    int _sockfd;
    std::string _inbuffer; // 充当缓冲区，vector<char>
    std::string _outbuffer;

    // 回指指针
    TcpServer *_owner;

    // client info
    InetAddr _client_addr;

    // 关心事件
    uint32_t _events;
};